package com.qf.cardlike.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author zed
 * @date 2022/5/5 11:04
 * 自定义拦截器
 */
public class MyInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        /*HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        if(Objects.isNull(user)){
            // 说明没有登录，拦截，返回到登录页面
            request.setAttribute("error","用户名或密码错误");
            request.getRequestDispatcher("/index.jsp").forward(request,response);
        }*/
        // 如果登录过，就放行
        return true;
    }

}
